<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/6/1 0001
 * Time: 21:40
 */

function callback_function (){
    swoole_timer_after(1, function (){
        global $aa;
        global $bb;
        $parms = json_decode($bb);
        $res = shell_exec($aa);
        //$resArr = Tools::baiduresultToArray($res);//拿到了结果，然后存入数据库
        $resArr = Tools::aliyunresultToArray($res);//拿到了结果，然后存入数据库
        $resStr = json_encode($resArr);//将得到的数组转化为json字符串
        if (file_exists($parms->tempPath)) unlink($parms->tempPath);
        $this->saveToSql($resStr, $parms);
    });
}
$workers             = [];        // 进程保存
$redirect_stdout    = false;
$process = new \swoole_process('callback_function',$redirect_stdout);
$process->start();